<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>call apply bind</title>
</head>
<body>
    <script type="module">
        // import {} from "./js/08_CallApplyBind/call_apply_bind.js"
        // 第1次写
        // import {} from "./js/08_CallApplyBind/call_apply_bind2.js"
        // 第2次写
        // import {} from "./js/08_CallApplyBind/call_apply_bind3.js"
        // 第3次写
        // import {} from "./js/08_CallApplyBind/call_apply_bind4.js"

        // 第4次写
        import {} from "./js/08_CallApplyBind/call_apply_bind5.js"
        var obj = {
            value: "the value",
        };

        function fn() {
            console.log(this.value);
        }
        new Promise((resolve, reject) => {
            return console.log(fn())
        }).catch(err => {
            console.log(err)
        })
        console.log('--------------- call ---------------')
        fn.myCall(obj)
        console.log('--------------- apply ---------------')
        fn.myApply(obj),
        fn.myApply(obj, [1, 2, 3])
        console.log('--------------- bind ---------------')
        let nFn = fn.myBind(obj)
        let nFn1 = fn.myBind(obj, [1, 2, 3])
        console.log(nFn())
        console.log(nFn1())
    </script>
</body>
</html>